package increment3;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
public class ShowHistory extends JFrame{
    JPanel jp;		//定义面板
    JList jl1;			//定义列表框
    JScrollPane jsp1;	//定义滚动
    JButton back = new JButton("退出");
    private GUIFunc func;
    private JPanel panel = new JPanel();
    private String name;
    private String pwd;
    public ShowHistory(String name, String pwd, ArrayList<String> his){
        this.name = name;
        this.pwd = pwd;
        this.setLayout(null);
        jp = new JPanel();
        jp.setBounds(0,50, 220,100);
        jl1=new JList(his.toArray());		//把经典添加到列表框中
        jl1.setVisibleRowCount(4);        //列表框只显示4个信息（必须要有滚动窗格连用才生效）
        jsp1=new JScrollPane(jl1);	//给列表框加一个滚动窗格
        //设置布局管理器
        jsp1.setBounds(0, 50, 220,100);
        JLabel  namelabel = new JLabel("用户:" + name);
        namelabel.setBounds(0, 10, 60, 20);
        back.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
        back.setBounds(60, 10, 60,20);
        jp.add(jsp1);
        this.add(namelabel);
        this.add(back);
        this.add(jp);
        this.setSize(220, 150);				//设置界面像素
        this.setLocation(500, 200);			//设置界面初始位置
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setVisible(true);				//设置界面可视化
    }
    public static void main(String[] args) {
        new ShowHistory("we", "sda", new ArrayList<String>());
    }
}
